﻿// JScript 文件
function ExecuteATool(id, params)
{
    if (!id)
    {
        return;
    }
    switch(id)
    {
        case m_vt.MAP_DRAG: //地图拖拽
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_DRAG);
        }break;
        case m_vt.MAP_PNTEXPAND://节点展开图


        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_PNTEXPAND);
            if (params)
            {
                if (params.length == 3)
                {
                    QuePntExpand(params[0], params[1], params[2]);
                }
//                else
//                {
//                    QueJDCLXX(params[0]);
//                }
            }
        }break;
        case m_vt.MAP_GDDEXPAND: //管道段展开图


        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_GDDEXPAND);
            if (params)
            {
                QueGddExpand(params[0], params[1], params[2]);
            }
        }break;
        case m_vt.MAP_ZOOMOUT://地图缩小
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_ZOOMOUT);
        }break;
        case m_vt.MAP_ZOOMIN: //地图放大
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_ZOOMIN);
        }break;
        case m_vt.MAP_RESET:
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.thisObj.SetToDefaultScale();
        }break;
        case m_vt.MAP_REFRESH:
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.clearMap();
        }break;
        case m_vt.MAP_LINESCALE: //距离量算
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_LINESCALE);
        }break;
        case m_vt.MAP_POLYAREA: //多边形面积量算

        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_POLYAREA);
        }break;
        case m_vt.MAP_CIRCAREA: //圆面积量算

        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_DRAWCIRCLE, {"Cb_Move" : win.thisObj.CircAreaMoveCb, "Cb_Up" : win.thisObj.CircAreaUpCb});
        }break;
        

        
        case m_vt.MAP_ADDRELATION: //添加关联线

        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_ADDRELATION);
        }
        break;
        case m_vt.MAP_SELECTRECT: //矩形查询
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_DRAWRECT, {"Cb_Up" : win.clearRect});
        }break;
        case m_vt.MAP_SELECTCIRC: //圆域查询
        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_DRAWCIRCLE,{"Cb_Up" : win.thisObj.CircAreaUpCb});
        }break;
        case m_vt.MAP_SELECTPOLY: //多边形查询


        {
            var win = m_doc.getWndElem(m_vt.MAP_MAP);
            win.UserMapOper.setOperator(m_vt.MAP_DRAWPOLY,{"Cb_DbClk" : win.MapGxOperObj.getEntByPoly.bind(win.MapGxOperObj)});
        }break;
        
         case m_vt.MAP_JXGQMAP: //局向光纤逻辑图


        {
            if(!params){params = {};}
            JxgqMap(params[0], params[1], params[2],params[3], params[4], params[5], params[6]);
        }break;
        case m_vt.MAP_TLCHECK: //通路检查


        {
            if(!params){params = {};}
            TlCheck(params[0], params[1], params[2],params[3], params[4], params[5], params[6], params[7]);
        }break;
         case m_vt.MAP_GRLYMAP: //光路路由图


        {
            GrLyMap(params[0], params[1], params[2]);
        }break;
        case m_vt.USER_LOGOUT: 
        {
            top.CtnDlg.confirm("是否注销?",
                function (flag)
                {
                    if (flag)
                    {
                        top.location.href = "Default.aspx";
                    }
                }
            );
            
        }break;
        case m_vt.USER_USER:
        case m_vt.USER_DEPT:
        case m_vt.USER_ROLE:
        {
            if(m_doc.objFramework.docBodyLeftState == 1)
            {
                m_doc.objFramework.docBodyLeftState = 0;
                m_doc.objFramework.reset();
            }
            if (params)
            {
                JumpToUser(params[0], params[1]);
            }
        }break;
        case m_vt.SYSCFG_FAVORITE:
        {
            AddBookMarks()
        }break;
        case m_vt.FUN_ATT:
        {
            QueAtt(params[0], params[1], params[2], params[3], params[4], params[5])
        }break;
        case m_vt.FUN_ATTBM:
        {
            QueAttBm(params[0], params[1], params[2], params[3], params[4], params[5])
        }break;
        case m_vt.FUN_LOC:
        {
            EntityLocatByNo(params[0], params[1], params[2])
        }break;
        case m_vt.FUN_LOCBM:
        {
            EntityLocatByBm(params[0], params[1], params[2])
        }break;
        case m_vt.FUN_QUEGJSB:       //光交设备查询
        {
            QueGjsb(params[0], params[1], params[2])
        }break;
        case m_vt.FUN_SELJXGQ:      //选择设备间的局向光纤

        {
            QueSelJxgq(params[0], params[1], params[2],params[3], params[4], params[5], params[6], params[7])
        }break;
        
         case m_vt.FUN_SELAJXGQ:    //选择两设备之间的局向光纤

        {
            QueSelAJxgq(params[0], params[1], params[2],params[3], params[4], params[5], params[6],params[7])
        }break;
        
       case m_vt.GQGRGL_GRCOMPARE:  //光路同缆检查

       { 
           GrCompare();  
       }break; 
       case m_vt.GQGRGL_LABELPRINT:  //标签打印
       { 
           LabelPrint(params[0],params[1]);  
       }break;  
       case m_vt.GQGRGL_TICKETPRINT:  //工单打印
       { 
           TicketPrint(params[0],params[1],params[2],params[3]);  
       }break;   
        case m_vt.QUERY_JDCLXX:       //节点穿缆信息
        {
            QueJDCLXX(params[0]);
        }break;
        case m_vt.QUERY_DDZMB:
        {
            QueDjMb(params[0], params[1], params[2])
        }break;
        case m_vt.QUERY_GDZMB:
        {
            QueGjMb(params[0], params[1], params[2])
        }break;
        case m_vt.QUERY_ENT:
        {
            if (params.length > 0 && params.length%2 == 0)
            {
                var vExp = "<items>"
                if (params.length > 2)
                {
                    for (var i = 2; i < params.length; i=i+2)
                    {
                        vExp += '<item col="'+params[i]+'" val="'+params[i+1]+'"></item>'
                    }
                }
                vExp += "</items>"
                QueEnt(params[0], params[1], vExp)
            }
        }break;
        case m_vt.QUERY_DZLIST:
        {
           QueDzList(params[0], params[1], params[2])
        }break;
        case m_vt.QUERY_JMPSB:        //查询跳接设备
        {
           QueJmpSb(params[0], params[1], params[2], params[3], params[4])
        }break;
        
        case m_vt.KJZYGL_DLDGL:
        {
            DldGl(params[0], params[1], params[2])
        }break;
        case m_vt.KJZYGL_GLDGL:
        {
            GldGl(params[0], params[1], params[2])
        }break;
        case m_vt.KJZYGL_DLGL:
        {
            GlTree(params[0], params[1], params[2],params[3])
        }break;
        case m_vt.KJZYGL_GLGL:
        {
            GlTree(params[0], params[1], params[2],params[3])
        }break;
        case m_vt.KJZYGL_XDINFO:
        {
            QueXdSy(params[0], params[1], params[2],params[3])
        }break;
        case m_vt.KJZYGL_GRINFO:
        {
            QueGrInfoByGl(params[0], params[1]);
        }break;
        case m_vt.KJZYGL_QUERYINFO:
        {
            QueryInfo(params[0], params[1], params[2])
        }break;
        case m_vt.KJZYGL_QUERYMOREINFO:
        {
            QueryMoreInfo(params[0], params[1], params[2])
        }break;  
        case m_vt.KJZYGL_YWBGL:    //营维部管理 
        {
            YwbManage(params[0], params[1], params[2], params[3], params[4], params[5]);
            window.vSelItem = params;
        }break;
        case m_vt.ASS_CFG0_PRJ:   
        case m_vt.ASS_CFG0_ATT:   
        case m_vt.ASS_CFG0_ATTCHG:
        case m_vt.ASS_CFG1_PRJ:   
        case m_vt.ASS_CFG1_ATT:   
        case m_vt.ASS_CFG1_ATTCHG:
        case m_vt.ASS_CFG2_PRJ:   
        case m_vt.ASS_CFG2_ATT:   
        case m_vt.ASS_CFG2_ATTCHG:
        case m_vt.ASS_CFG2_ZKP:   
        case m_vt.ASS_CFG2_ZKPCHG:
        case m_vt.ASS_CFG2_ATT1:
        case m_vt.ASS_CFG2_ATT2:
        case m_vt.ASS_CFG3_PRJ:   
        case m_vt.ASS_CFG3_ATT:   
        case m_vt.ASS_CFG3_ATTCHG:
        case m_vt.ASS_CFG3_ZKP:   
        case m_vt.ASS_CFG3_ZKPCHG:
        case m_vt.ASS_CFG3_ATT1:
        case m_vt.ASS_CFG3_ATT2:
        {
            top.CtnDlg.open("Asset/AssetCfg.aspx?" + id, {title:params,width:400,height:300});
        }break;
        case m_vt.ASS_GCZGGL:     //工程转固管理
        case m_vt.ASS_ZCXZGL:
        case m_vt.ASS_ZCBFGL:
        case m_vt.ASS_ZCDBGL:
        case m_vt.ASS_ZCXSGL:  
        case m_vt.ASS_ZCCZGL:     //资产出租管理
        case m_vt.ASS_ZCJZGL:
        case m_vt.ASS_ZCJZGL:
        case m_vt.ASS_ZCSYGL:
        case m_vt.ASS_ZCKPGL:      
        {
            top.m_doc.createWnd(new CtnTool(id ,params, "main", "Asset/AssetMain.aspx?idx=" + id));
        }break;
        case m_vt.ASS_TREE:
        {
            var xmlDoc = CtnTrans.getXml("/main.ashx?_Method=GetAssMainCfg", "POST", "idx=" + m_vt.ASS_TREE);
            if(!CtnError.validate(xmlDoc))
            {
                CtnError.show();
                return;
            };
            var nodes = xmlDoc.selectNodes("i/i/i/i");
            for(var i = 0; i < nodes.length; i++)
            {
                m_doc.createWnd(new CtnTool($XML(nodes[i], "idx") , $XML(nodes[i], "name"), "left", "Asset/AssetTree.aspx?" + $XML(nodes[i], "idx")));
            }
        }break;
        case m_vt.ASS_GGCSPZGL:
        {
            top.m_doc.createWnd(new CtnTool(id ,"规格程式配置管理", "main", "Asset/SpecCfgMng.aspx?" + id));
        }break;
        case m_vt.ASS_DWGLGJ:
        {
            top.m_doc.createWnd(new CtnTool(id ,"单位管理工具", "main", "Asset/AssetDwMng.aspx?" + id));
            //top.m_doc.createWnd(new CtnTool(id ,"单位管理工具", "main", "Asset/AssDwGsZzgl.aspx?" + id));
        }break;
        case m_vt.ASS_MAIN:
        {
            top.m_doc.createWnd(new CtnTool(id ,"资产流程向导", "main", "Asset/AssetMain.aspx?idx=" + id + "&bmlx=OUTERFLAG&bm=" + params[0] + "&id0=" + params[1] +"&random=" + new Date().getTime()));
        }break;
        case m_vt.GQGRGL_GRCFG:
        {
            var Title = "资源配置"
            if(params != undefined)
            {
                if(params[0].DzType == "1")
                {
                    Title = "光路调整";
                }
                top.m_doc.createWnd(new CtnTool(id ,Title, "main", "GqGr/GrCfg.aspx?oper="+params[0].DzType+"&serialno="+params[0].SerialNo+ "&bsf=" + params[0].IsSF + "&bm=" + params[0].GluBm + "&GrPzType=" + params[0].GrPzType + "&GrType="+ params[0].GrType +"&TicketNo="+params[0].TicketNo+"&justbm="+params[0].newBm+"&taskitem="+params[0].Task+"&BjoperCode="+params[0].BjoperCode));
            }
            else
            {
                top.m_doc.createWnd(new CtnTool(id ,Title, "main", "GqGr/GrCfg.aspx"));
            }
        }
        break;
        case m_vt.GQGRGL_GRTJXQ:
        {
            var vTitle = "订单详情"
            if(params[5] == "0")
            {
                vTitle = "工单详情"
            }
            top.CtnDlg.open("GqGr/TjXq.aspx?Qy="+params[0]+"&Dz="+params[1]+"&Yw="+params[2]+"&QsSj="+params[3]+"&ZzSj="+params[4]+"&Type="+params[5], {title:vTitle,width:700,height:500});
        }
        break;
        case m_vt.GQGRGL_NEXTENTITY:
        {
            NextEntity(params[0], params[1], params[2], params[3], params[4], params[5]);
        }break;
        case m_vt.ECON_ALERTGUIDE:
        {
            showAlertFlag();
        }break;
        case m_vt.KJZYGL_XGTX:
        {
            EditMapTool(params[0], params[1], params[2], params[3], params[4]);
        }break;
        case m_vt.KJZYGL_SCTX:
        {
            DeleMap(params[0], params[1], params[2])
        }break;
        case m_vt.KJZYGL_TJTX:
        {
            AddMapTool(params[0], params[1], params[2], params[3], params[4])
        }
        break;
        default:    
        break;
    }
}

//查看属性





function QueAtt(maj, min, ent, act, fun, dft)
{
   if (fun != null)
   {
        top.CtnDlg.open("Dialog/Att.aspx?major="+maj+"&minor="+min+"&action="+act+"&id="+ent+"&default="+dft, {title:"属性",width:400,height:500,arrbtn:[{text:"确定",onClick:fun},{text:"取消",onClick:function(dlg){dlg.close();}}]});
   }
   else
   {
        top.CtnDlg.open("Dialog/Att.aspx?major="+maj+"&minor="+min+"&action="+act+"&id="+ent+"&default="+dft, {title:"属性",width:400,height:500,arrbtn:[{text:"确定",onClick:function(dlg){dlg.close();}},{text:"取消",onClick:function(dlg){dlg.close();}}]});
   }
    
}


//光交设备查询  --- 编号：1008

function QueGjsb(GrType,fun,bSelcfgType)
{
     if(bSelcfgType)
     {
         top.CtnDlg.open("GqGr/Query.aspx?GrType="+GrType+"&dispType="+1, {title:"光交设备查询",width:700,height:500,arrbtn:[{text:"手动配纤",onClick:function (dlg){fun(dlg,1);}},{text:"图形配纤",onClick:function (dlg){fun(dlg,2);}},{text:"取消",onClick:function(dlg){dlg.close();}}]});

     }
     else
     {
         top.CtnDlg.open("GqGr/Query.aspx?GrType="+GrType+"&dispType="+0, {title:"光交设备查询",width:700,height:500,arrbtn:[{text:"确定",onClick:fun},{text:"取消",onClick:function(dlg){dlg.close();}}]});
     }
}

//选择路由段局向光纤  --- 编号：1008


function QueSelJxgq(GrType,entlist,qsenttype,zzenttype,Qx,bjump,bcheck,fun)
{
    var Url = "GqGr/SelJxgqInfo.aspx?GrType=" + escape(GrType);
    if(entlist)     Url += "&entlist=" + escape(entlist);
    if(qsenttype)   Url += "&qsenttype=" + escape(qsenttype);
    if(zzenttype)   Url += "&zzenttype=" + escape(zzenttype);
    if(Qx)          Url += "&Qx=" + escape(Qx);    
    if(bjump)       Url += "&bjump=" + escape(bjump);    
    if(bcheck)      Url += "&bcheck=" + escape(bcheck); 


   top.CtnDlg.open(Url, {title:"局向光纤列表",width:900,height:600,arrbtn:[{text:"确 定",onClick:fun},{text:"取 消",onClick:function(dlg){dlg.close();}}]});
}

//选择两设备间的局向光纤  --- 编号：1008


function QueSelAJxgq(tit,GrType,qsbm,zzbm,qsenttype,zzenttype,Qx,fun) //标题，光路类型，起始编码，终止编码，起始类型，终止类型，纤芯数，回调函数
{
    var Url = "GqGr/SelAJxgq.aspx?GrType=" + escape(GrType);
    if(qsbm)     Url += "&qsbm=" + escape(qsbm);
    if(zzbm)     Url += "&zzbm=" + escape(zzbm);
    if(qsenttype)   Url += "&qsenttype=" + escape(qsenttype);
    if(zzenttype)   Url += "&zzenttype=" + escape(zzenttype);
    if(Qx)          Url += "&Qx=" + escape(Qx);    
   
    
   top.CtnDlg.open(Url, {title:tit,width:800,height:520,arrbtn:[{text:"确 定",onClick:fun},{text:"取 消",onClick:function(dlg){dlg.close();}}]});
}


// 查询跳接的设备   --- 编号：1008

function QueJmpSb(entbm,fun,grtype,dzbm,dis)    //实体编码(not null)，光路类型，端子编码，搜索范围

{
    var Url = "GqGr/GetJmpSb.aspx?entbm=" + escape(entbm);
    if(grtype)   Url += "&GrType=" + escape(grtype);
        
    if(dzbm)     Url += "&dzbm=" + escape(dzbm);
    
    if(dis)      Url += "&dis=" + escape(dis);
    
    var dlg = top.CtnDlg.open(Url,{title:"选择跳接的设备",width:720,height:520,arrbtn:[{text:"确 定",onClick:fun},{text:"取 消",onClick:function(dlg){fun(dlg,true);dlg.close();}}]});
    
    dlg.entbm = entbm;
    dlg.dzbm = dzbm;
    dlg.wnd.m_dlg = dlg;    //当前dlg对象复制到子窗口
    dlg.wnd.closedlg = function(dlg)
    {
       fun(dlg,true)     //true表示无返回值

       dlg.close();
    }
}

//通路检查    --- 编号：1008
//GrType 光路类型,Qx 光路纤芯数,qsent 起始实体,qslay 起始实体层,zzent 终止实体,zzlay 终止实体层,bcfg 是否返回配置结果,fun 回调函数

function TlCheck(GrType,Qx,qsent,qslay,zzent,zzlay,bcfg,fun)
{
    var Url = "GqGr/checkTl.aspx?GrType="+ GrType;
    
    if(qsent)   Url += "&qsent=" + escape(qsent);
    if(qslay)   Url += "&qslay=" + escape(qslay);
    if(zzent)   Url += "&zzent=" + escape(zzent);
    if(zzlay)   Url += "&zzlay=" + escape(zzlay);
        
    if(Qx)      Url += "&qx=" + Qx;
    
    if(bcfg)    Url += "&bcfg=" + bcfg;
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.MAP_TLCHECK,"通路检查", "main", Url));
    var win = m_doc.getWndElem(m_vt.MAP_TLCHECK);
    win.resfun = fun;
}

//局向光纤逻辑图   --- 编号：1008

function JxgqMap(GrType,Qx,entlay,bcfg,entbm,fun)
{
    var Url = "GqGr/JxgqMap.aspx?GrType="+ GrType;
    
    if(entbm)   Url += "&entbm=" + escape(entbm);
        
    if(Qx)     Url += "&Qx=" + Qx;
    
    if(entlay)      Url += "&entlay=" + entlay;
    
    if(bcfg)      Url += "&bcfg=" + bcfg;
    
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.MAP_JXGQMAP,"局向光纤逻辑图", "main", Url));
    var win = m_doc.getWndElem(m_vt.MAP_JXGQMAP);
    win.resfun = fun;
}

//光路路由图   --- 编号：1008



function GrLyMap(grbm,GrType,blogicmap)
{
   top.CtnDlg.open("GqGr/GrLyMap.aspx?grbm="+grbm+"&GrType="+GrType+"&blogicmap="+blogicmap, {title:"光路路由图",width:800,height:550,arrbtn:[{text:"关 闭",onClick:function(dlg){dlg.close();}}]});

}

function GrCompare()
{
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.GQGRGL_GRCOMPARE,"光路同缆查询", "main", "GqGr/GrCompare.aspx"));  
}

function LabelPrint(bmlist,grtype)
{
    var url = "GqGr/LabelPrint.aspx?GrBm="+escape(bmlist)+"&GrType="+grtype;
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.GQGRGL_LABELPRINT,"标签打印", "main", url));  
}

function TicketPrint(Grbm,Grtype,bDelGr,Gdbh)
{
    var url = "GqGr/TicketPrint.aspx?GrBm="+escape(Grbm)+"&GrType="+Grtype+"&bDelGr="+bDelGr+"&Gdbh="+Gdbh;
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.GQGRGL_TICKETPRINT,"工单打印", "main", url));  
}
//节点展开图


function QuePntExpand(major, minor, entityNo)
{
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.MAP_PNTEXPAND,"节点展开图", "main", "PntExpand/PntView.aspx?Major=" + major + "&Minor=" + minor + "&No=" + entityNo));
}
//管道段展开图


function QueGddExpand(major, minor, entityNo)
{
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.MAP_GDDEXPAND,"管道段展开图", "main", "PntExpand/LinView.aspx?Major=" + major + "&Minor=" + minor + "&GddNo=" + entityNo));
}

//function QueJDCLXX(strTreeXml)
//{
//    top.CtnDlg.open("PntExpand/PntExpandTree.aspx", {title:"节点穿缆信息", width:400,height:500, srcwin:window,strtreexml:strTreeXml});
//}

function JumpToUser(operType,userId)
{
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.USER_USER,"用户管理", "main", "user/MngUserDesc.aspx?Oper=" + operType + "&userID="+ userId));
}
//光交设备面扳  --- 编号：1008
function QueGjMb(maj, min, ent)
{
    var url = "GjsbManage/GjsbMb.aspx?Major="+maj+"&Minor="+min+"&No="+ent;
    top.m_doc.createWnd(new top.CtnTool(top.m_vt.QUERY_GDZMB, "光交设备面板", "main", url));
}

//电交设备面板
function QueDjMb(maj, min, ent)
{
    var url = "PntManager/EPortMod.htm?major="+maj+"&minor="+min+"&no="+ent;
    top.m_doc.createWnd(new CtnTool(top.m_vt.QUERY_DDZMB, "电交设备面板", "main", url));
}

function QueAttBm(maj, min, bm, act, fun, dft)
{
   if (fun != null)
   {
        top.CtnDlg.open("Dialog/Att.aspx?major="+maj+"&minor="+min+"&action="+act+"&bm="+bm+"&default="+dft, {title:"属性",width:400,height:500,arrbtn:[{text:"确定",onClick:fun},{text:"取消",onClick:function(dlg){dlg.close();}}]});
   }
   else
   {
        top.CtnDlg.open("Dialog/Att.aspx?major="+maj+"&minor="+min+"&action="+act+"&bm="+bm+"&default="+dft, {title:"属性",width:400,height:500,arrbtn:[{text:"确定",onClick:function(dlg){dlg.close();}},{text:"取消",onClick:function(dlg){dlg.close();}}]});
   }
    
}
//综合查询
function QueEnt(maj, min, exp)
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.QUERY_ENT, "综合查询", "main", "Dialog/Query.aspx?major="+maj+"&minor="+min+"&exp="+escape(exp)));
}

//加入收藏
function AddBookMarks()
{
   if (window.sidebar) 
   { 
        window.sidebar.addPanel("中国电信资源管理系统", window.location.href,""); 
   } 
   else if( document.all ) 
   {
        window.external.AddFavorite( window.location.href, "中国电信资源管理系统");
   } 
   else if( window.opera && window.print ) 
   {
        return true;
    }
}
//电缆段管理


function DldGl(Maj,Min,EntId)
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_DLDGL, "电缆段管理", "main", "SpaceRes/DldManage.aspx?major="+Maj+"&minor="+Min+"&id="+EntId));
}
//光缆段管理


function GldGl(Maj,Min,EntId)
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_GLDGL, "光缆段管理", "main", "SpaceRes/GldManage.aspx?major="+Maj+"&minor="+Min+"&id="+EntId));
}
//电缆、光缆管理树
function GlTree(maj, min, ent,type)
{   
    if(type == "0")
    {
        top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_DLGL, "电缆管理", "left", "SpaceRes/GlTree.aspx?major="+maj+"&minor="+min+"&id="+ent+"&Treetype="+type));
    }
    else
    {
        top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_GLGL, "光缆管理", "left", "SpaceRes/GlTree.aspx?major="+maj+"&minor="+min+"&id="+ent+"&Treetype="+type));
    }

}
//查看电缆线对信息
function QueXdSy(Maj,Min,EntId,DldId)
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_XDINFO,"线对使用信息","main","SpaceRes/XdSyqk.aspx?sMajor="+Maj+"&sMinor="+Min+"&EntId="+EntId+"&DldId="+DldId));
}
//查看光路信息
function QueGrInfoByGl(Min, EntNo)
{
    //top.CtnDlg.open("SpaceRes/GrInfo.aspx?sMajor="+Maj+"&sMinor="+Min+"&EntId="+EntId, {title:"光路属性",width:600,height:300});
    
    top.CtnDlg.open("Dialog/GlGrList.aspx?minor="+Min+"&EntityNo="+EntNo, {title:"光路属性",width:700,height:500});
}
function QueryInfo(maj, min, fun)
{
    top.CtnDlg.open("Dialog/Query.aspx?major="+maj+"&minor="+min, {title:"实体查询",width:700,height:500,arrbtn:[{text:"确定",onClick:fun},{text:"取消",onClick:function(dlg){dlg.close();}}]});
}
function QueryMoreInfo(maj, min, fun)
{
    top.CtnDlg.open("Dialog/QueryMore.aspx?major="+maj+"&minor="+min, {title:"实体查询",width:700,height:500,arrbtn:[{text:"确定",onClick:fun},{text:"取消",onClick:function(dlg){dlg.close();}}]});
}

//查看光交设备端子信息列表   --- 编号：1008

function QueDzList(maj,min,ent)  
{
   top.CtnDlg.open("Dialog/GjsbDzList.aspx?major="+maj+"&minor="+min+"&EntityNo="+ent, {title:"光交设备端子信息",width:700,height:500,arrbtn:[{text:"关 闭",onClick:function(dlg){dlg.close();}}]});
   
} 

function YwbManage(Maj, Min, Id, GlId, Text, Type)  //营维部管理

{
    if(Text=="FGFW")
    {
        YwbFgfwMsg(Maj, Min, Id, GlId,Type);
    }
    else
    {
        top.m_doc.createWnd(new CtnTool(top.m_vt.KJZYGL_YWBGL,"营维部管理","main","SpaceRes/YwbManage.aspx?Major="+Maj+"&Minor="+Min+ "&EntId=" + Id + "&GlId=" + GlId + "&YwbText=" + Text+ "&Type=" + Type));
    }
    
}
function YwbFgfwMsg(major, minor, jlId, glId,type)//营维部覆盖范围管理

{
    //JlId为经理ID
    switch(type)
    {
        case "ZDBUILD"://自动生成覆盖范围
        {
            var bDispClientEnt = false ;
            CtnTrans.Ajax("/main.ashx?","post","_method=ZDBUILD&Major=" + major + "&Minor=" + minor+"&JlId="+jlId+"&GlId="+glId, DrawFgFwShape,{maj:major,min:minor,ent:jlId,bdisp:bDispClientEnt},{loading:true});
        }
        break;
        case "EDIT"://编辑该经理的覆盖范围
        {
              UpdateAGraph(major,minor,jlId,true)
        }
        break;
        default:
        break;
    }
}

//自动生成覆盖范围
function DrawFgFwShape(Res, obj)
{
    if(Res.responseText == "")
    {
        EntityLocatByNo(obj.maj,obj.min,obj.ent)
    }
    else
    {
        var xmlDoc = CtnXML.getXmlDoc();
        xmlDoc.loadXML(Res.responseText)
        if (!CtnError.validate(xmlDoc))
        {
              CtnError.show();
              return ;
        }
    }
}
//修改覆盖范围
function UpdateAGraph(major,minor,jlId,bDispClientEnt)
{
     var win = m_doc.getWndElem(m_vt.MAP_MAP);
     EntityLocatByNo(major,minor,jlId,bDispClientEnt)
     win.UserMapOper.ActiveTool = 20008;
     win.UserMapOper.Cb_DbClk = win.MapGxOperObj.SaveDate.bind(win.MapGxOperObj);
     //win.UserMapOper.setOperator(20008,{"Cb_DbClk" : win.MapGxOperObj.SaveDate.bind(win.MapGxOperObj)});
}
//function GrCfg(item)
//{
//    top.m_doc.createWnd(new CtnTool(top.m_vt.GQGRGL_GRCFG,"资源配置","main","GqGr/GrCfg.aspx?oper="+item+"&SerialNo="+item+ "&IsSF=" + item + "&GluBm=" + item + "&GrPzType=" + item+ "&newBm=" + item + "&GrType"+ item +"&TicketNo="+item+));
//}
function NextEntity(bm,LjBmList,QxTotal,EntityType,m_GrType,DzBm)
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.GQGRGL_NEXTENTITY,"向前配置","main","GqGr/NextEntity.aspx?CurrentBm="+bm+"&LjBmList="+LjBmList+ "&QxTotal=" + QxTotal + "&EntityType=" + EntityType + "&m_GrType=" + m_GrType+ "&DzBm=" + DzBm));
}
////////////////////////////////实体定位///////////////////////////////////
////根据实体号定位实体   --- 编号：1008

////major            实体主类型

////minor            实体子类型

////entityNo         实体ID0
////bDispClientEnt   是否显示客户端所有实体  --默认显示 false或不给值      不显示时 true
function EntityLocatByNo(major,minor,entityNo,bDispClientEnt)
{
   var serverUrl = "_method=EntityLocByNo"
                      + "&MAJOR=" + escape(major)
                      + "&MINOR=" + escape(minor)
                      + "&ENTITYNO=" + escape(entityNo);
                      
   CtnTrans.Ajax("/main.ashx","post",serverUrl, EntityNoLocat,{maj:major,min:minor,ent:entityNo,bdisp:bDispClientEnt}, {loading:true});
}

function EntityNoLocat(response,params)
{
   //设置当前活动窗口
   m_doc.setActive(m_vt.MAP_MAP)
   //获取地图对象操作句柄
   var win_Map = m_doc.getWndElem(m_vt.MAP_MAP);
   //获得定位的图形信息，用于修改图形
   window.responseText = response.responseText;
   win_Map.MapGxOperObj.EntityLocat(params.maj,params.min,params.ent,response.responseText,params.bdisp)
}

function EntityLocatByBm(major,minor,entityBm,bDispClientEnt)
{
    var serverUrl = "_method=EntityLocByBm"
                      + "&MAJOR=" + escape(major)
                      + "&MINOR=" + escape(minor)
                      + "&ENTITYBM=" + escape(entityBm);
    CtnTrans.Ajax("/main.ashx","post",serverUrl, EntityBmLocat,{maj:major,min:minor,bdisp:bDispClientEnt}, {loading:true});
}

function EntityBmLocat(response,params)
{
   //设置当前活动窗口
   m_doc.setActive(m_vt.MAP_MAP)
   //获取地图对象操作句柄
   var win_Map = m_doc.getWndElem(m_vt.MAP_MAP);
   var vsplit = response.responseText.split('|||')
   var entityNo = vsplit[0]
   var ventXml = vsplit[1]
   win_Map.MapGxOperObj.EntityLocat(params.maj,params.min,entityNo,ventXml,params.bdisp)
}

function CreateEntTree()
{
    top.m_doc.createWnd(new CtnTool(top.m_vt.MAP_SELECTENT ,"实体图", "main", "Dialog/EntTree.htm?" + new Date().getTime()));
}
function QuerySql(major, minor, func)
{
    CtnDlg.open("Dialog/QuerySql.aspx?major=" + major + "&minor=" + minor, {title:"输入条件查询", width:450, height:300, arrbtn:[{text:"确定", onClick:function(dlg){func(dlg.wnd.getSql());dlg.close();}},{text:"取消", onClick:function(dlg){dlg.close();}}]});
}
function Validate(win)
{
    var arrInput = win.document.getElementsByTagName("input");
    for (var i = 0; i < arrInput.length; i++)
    {
        if (arrInput[i].type.toLowerCase() == "button")
        {
            if (!IsNaN(parseInt(arrInput[i].name)))
            {
                if (!CanOperFunc(arrInput[i].name))
                {
                    arrInput[i].disabled = true;
                }
            }
        }
    }
    
}
//功能点鉴权

function CanOperFunc(toolid)
{
    if (!m_doc.bValidate)
    {
        return true;
    }
    var arrFunc = m_doc.arrFunc;
    for (var i = 0; i < arrFunc.length; i++)
    {
        if (arrFunc[i] == toolid)
        {
            return true;
        }
    }
    return false;
}
//验证某个菜单项是否有权限
function CanOperMenu(menu)
{
    if (!m_doc.bValidate)
    {
        return true;
    }
    if ($XML(menu, "id") != null)
    {
        var id = $XML(menu, "id");
        if (isNaN(id))//如果是变量名
        {
            return CanOperFunc(m_vt[id]);
        }
        else//如果是值

        {
            return CanOperFunc(id);
        }
    }
    else
    {
        var tools = menu.selectNodes("tool");
        for (var i = 0; i < tools.length; i++)
        {
            var id = $XML(tools[i], "id");
            if (isNaN(id))
            {
                id = m_vt[id];
            }
            if (CanOperFunc(id))
            {
                return true;
            }
        }
        var menus = menu.selectNodes("sidemenu");
        for (var i = 0; i < menus.length; i++)
        {
            var id = $XML(menus[i], "id");
            if (isNaN(id))
            {
                id = m_vt[id];
            }
            if (CanOperFunc(id))
            {
                return true;
            }
        }
    }
    return false;
}
//修改营维社区的覆盖范围

function EditFgFwShape()
{

}
//一进系统，提示预警信息
function showAlertFlag()
{
    var serverUrl ="_method=GetAlertInfo" + "&init=1&pageno=1&flag=1";                  
    var vXml = top.CtnTrans.getText("/main.ashx?", "post", serverUrl)
    if (!top.CtnError.validate(vXml))
    {
         top.CtnError.show();
         return;
    }
    else
    {
        if(vXml == "有预警信息")
        {
            if(confirm("有预警信息，需要查看吗?"))
            {
                var tool = new CtnTool();
                tool.id = m_vt.ECON_NAV;
                tool.name = "经营分析";
                tool.target = "right";
                tool.url = "/Cfg/EconMenu.xml";
                top.m_doc.createSideMenu(tool);
            }
        }
    }
}
function AddMapTool(maj,min,id, map, mytype)
{
    var win = m_doc.getWndElem(top.m_vt.MAP_MAP);
     switch (parseInt(map))
     {
         case 1://点         {
             win.UserMapOper.setOperator(m_vt.MAP_DRAWLINE,{"Cb_DbClk" : AddMapGraph, "DbClk_Params":[maj,min,id,mytype]});
         }
         break;
         case 2://线         {
             win.UserMapOper.setOperator(m_vt.MAP_DRAWLINE,{"Cb_DbClk" : AddMapGraph, "DbClk_Params":[maj,min,id,mytype]});
         }
         break;
         case 3://区         {
             win.UserMapOper.setOperator(m_vt.MAP_DRAWPOLY,{"Cb_DbClk" : AddMapGraph, "DbClk_Params":[maj,min,id,mytype]});
         }
         break;
     }
}
function AddMapGraph(dot,temp)
{
    if (!temp) return;
    var win = m_doc.getWndElem(top.m_vt.MAP_MAP);
    
    var vInfo = "<data major='"+ temp[0] +"' minor='"+ temp[1] +"' id='"+temp[2]+"' mytype='"+temp[3]+"'>";
    vInfo += "<map>";
    for(var i = 0;i<dot.length;i++)
    {
        vInfo += "<item x='"+dot[i].lx+"' y='"+dot[i].ly+"'>";
        vInfo += "</item>";
    }
    vInfo += "</map>";
    vInfo += "</data>";
    var xmlDoc = CtnTrans.getXml("/main.ashx?_method=AddMap", "post", escape(vInfo));
    if(xmlDoc.text == "")
    {
        CtnDlg.msg("操作成功!");
    }
    else if (!CtnError.validate(xmlDoc))
    {
        CtnError.show();
        return;
    }
}
function EditMapTool(Maj, Min, Id, maptype, mytype)
{
    var win = m_doc.getWndElem(m_vt.MAP_MAP);
    win.PolyPen.UnDraw();
    win.PolyPen.dotArr = null;
    win.PolyPen.dotArr = new Array();
    EntityLocatByNo(Maj,Min,Id,true);
    win.UserMapOper.setOperator(m_vt.KJZYGL_SCTX ,{"Cb_Up" : DeleteDate, "Up_Params":[Maj,Min,Id,"Edit", maptype, mytype]});
}

function DeleMap(Maj, Min, Id)
{
    var win = m_doc.getWndElem(m_vt.MAP_MAP);
    win.PolyPen.UnDraw();
    win.PolyPen.dotArr = null;
    win.PolyPen.dotArr = new Array();
    EntityLocatByNo(Maj,Min,Id,true)
    win.UserMapOper.setOperator(m_vt.KJZYGL_SCTX ,{"Cb_Up" : DeleteDate, "Up_Params":[Maj,Min,Id,"Delete"]});
}
function DeleteDate(temp)
{
    var win = m_doc.getWndElem(m_vt.MAP_MAP);
    if(win.isinclud)
    {
        var showmsg = "";
        if(temp[3] == "Delete")
        {
            showmsg = "确认是否删除该图形?";
        }
        else if(temp[3] == "Edit")
        {
            showmsg = "确认是否修改该图形?";
        }
        if (confirm(showmsg))
        {
            var vParam = "_method=DeleteMap&major="+temp[0] + "&minor=" +temp[1]+"&gid="+win.MapGxOperObj.rectidList[win.rectIndex] ;
            var xmlDoc = CtnTrans.getText("/main.ashx", "post", vParam)
            if(xmlDoc == "")
            {
                for(var i = win.MapGxOperObj.flashNodes.length-1; i>=0;i--)
                {
                    if(i == win.rectIndex)
                    {
                        win.MapGxOperObj.flashNodes.splice(i,1);
                    }
                }
                for(var i = win.MapGxOperObj.rectidList.length-1; i>=0;i--)
                {
                    if(i == win.rectIndex)
                    {
                        win.MapGxOperObj.rectidList.splice(i,1);
                    }
                }
                
                win.MapGxOperObj.DrawFlashLin();
                if(temp[3] == "Delete")
                {
                    top.CtnDlg.msg("删除成功!");
                }
                else if(temp[3] == "Edit")
                {
                    top.CtnDlg.msg("请添加新图形!");
                    AddMapTool(temp[0],temp[1],temp[2], temp[4], temp[5]);
                }
            }
            else if (!CtnError.validate(xmlDoc))
            {
                CtnError.show();
                return;
            }
        }
    }
}
/////////////////////////////////////////////////////////////////////////////